<template>
	<view>
		测试链接
	</view>
</template>

<script>
	import Index from '@/common/index-model.js'
	let index = new Index();
	let that = null;
	export default {
		data() {
			return {
				iv: '', //加密信息算法
				encryptedData: '', //加密信息
			}
		},
		onLoad() {
			uni.showShareMenu({
				withShareTicket: true,
				menus: ["shareAppMessage"],
			})
			const enterOptions = uni.getEnterOptionsSync();
			if (enterOptions.scene === 1044) {
				this.getGroupInfo();
			}
		},
		onShareAppMessage() {
			return {
				title: "自定义转发标题",
				path: "pages/getopengid/getopengid",
			};
		},
		methods: {
			getGroupInfo() {
				// 判断接口是否可用
				if (wx.getGroupEnterInfo) {
					wx.getGroupEnterInfo({
						needGroupOpenID: true, // 必填参数
						success: (res) => {
							console.log("?")
							this.iv = res.iv
							this.encryptedData = res.encryptedData
							console.log('群信息:', this.iv, this.encryptedData);
							this.startget()
						},
						fail: (err) => {
							console.error('获取失败:', err);
						}
					});
				} else {
					// 兼容低版本
					uni.showModal({
						title: '提示',
						content: '您的微信版本过低，请升级后使用'
					});
				}
			},
			startget(){
				if (!uni.getStorageSync('token')) {
					index.show_tips('请先登录')
					setTimeout(() => {
						index.navigate_to('../../pagesC/login/login');
						//index.navigate_back(1)
					}, 300)
					return
				}
				index.getPublicUserMember({
					encryptedData: this.encryptedData,
					iv: this.iv,
				}, '/apclient/appUserPrizeDrawRecord/getWxOperationId', 'post', res => {
					if (res.data.code == 200 && res.data.success) {
						index.show_tips("已记录");
					} else {
						index.show_tips(res.data.message);
						return
					}
				})
			}
		}
	}
</script>

<style>

</style>